package com.itbaizhan.consumer;

import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * 消费者
 */
@Service
@RocketMQMessageListener(
        // 主题
        topic = "${demo.rocketmq.topic}",
        // 消费组
        consumerGroup = "${demo.rocketmq.consumerGroup}",
        // 过滤方式 默认 tag
        selectorType = SelectorType.TAG,
        // 过滤值 默认全部消费
        selectorExpression = "a",
        // 消费的模式  顺序消费ORDERLY    并发消费CONCURRENTLY
        consumeMode = ConsumeMode.ORDERLY ,
        // 消息模式 集群消费CLUSTERING   广播消费 广播
        messageModel = MessageModel.CLUSTERING
)
public class MessageConsumer implements RocketMQListener<String> {
    @Override
    public void onMessage(String message) {
        System.out.println(message);
    }
}
